jQuery(document).ready(function() {
	//创建JQGRID表格
	var grid = $("#table1").ligerGrid({
        columns: [
                  { display: '出库单号', name: 'outwhCode', width: 200 },
                  { display: '出库仓库', name: 'whName', width: 200},
                  { display: '状态', name: 'billStatus', width: 200,
                	render : function(item){
                		if (item.billStatus == 1)
                			return "草稿";
                		if (item.billStatus == 2)
                			return "审批中";
                		if (item.billStatus == 3)
                			return "完成";
                	}  
                  },
                  { display: '出库时间', name: 'dctime', width: 200,
                	  render: function (item){
                		  var cdate=new Date(item.dctime);
                		  return formatDate(cdate,"yyyy-MM-dd")
                	  }
                  },
                  { display: '制单人', name: 'aegnt', width: 200 }
                  ],  usePager: true,pageSize:30,
                      url : basic_Url+"/list.do",
                      width: '100%', height: '98%', checkbox: true,rownumbers:true,
                      enabledSort:false,
                      onDblClickRow : function (data, rowindex, rowobj){
                          edit(data);
                       }
                  });
	$("#pageloading").hide();
	
	
});

function checkdel(){
	var manager = $("#table1").ligerGetGridManager(); 
	var rows =manager.getSelectedRows();
	var bol = false;
	if (rows==null || 0 == rows.length){
			$.dialog.alert('请选择需要操作删除的行！');
			return;
	}
	for(var i=0;i<rows.length;i++){
	 	if (rows[i].aegnt != user){
	 		bol = true;
		}
	}
	if(bol){
		$.dialog.alert('请选择自己创建的草稿单据进行删除操作!');
		return;
	}else{
		bol = false;
		for(var i=0;i<rows.length;i++){
		 	if (rows[i].billStatus>1){
		 		bol = true;
			}
		}
		if(bol){
			$.dialog.alert('非草稿状态的单据不能删除!');
			return;
		}else{
			del();
			bol = false;
		}
	}	
}
